<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>方案列表</title>
    <link rel="stylesheet" href="__TEMPLATE__/layui/css/layui.css">
    <style>
        .layui-form-label {
            width: 150px;
        }

        .layui-input-block {
            margin-left: 180px;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">医院档案</div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;"><?php echo @$_SESSION['username']; ?></a>
            </li>
            <li class="layui-nav-item"><a href="javascript:;" id="logout">退出</a></li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree">
                <li class="layui-nav-item layui-this"><a href="index.php">病例列表</a></li>
            </ul>
        </div>
    </div>
    <div class="layui-body" style="padding: 20px;">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>方案列表</legend>
        </fieldset>
        <div class="message_body">
            <ul>
                <?php
            foreach ($messageList as $key => $value) {
                $role = '';
                if ($value['admin_role'] == 1) {
                $role = '医生';
                } else if ($value['admin_role'] == 2) {
                $role = '专家';
                }
                echo '
                <div class="layui-form-item layui-form-text"><label class="layui-form-label">'.$value['username'].$role.'：</label>
                    <div class="layui-input-block" style="padding-top: 9px;">'.$value['message'].'</div>
                </div>
                ';
                }
                ?>
            </ul>
        </div>
        <form class="layui-form" action="" lay-filter="form">
            <input type="hidden" name="case_list_id" value="{%case_list_id%}"/>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">回复：</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入回复" class="layui-textarea" name="message"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
                    <?php
                        if (@$_SESSION['admin_role'] == 2) {
                    ?>
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="submitFangan">确定方案</button>
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="resetFangan">重置方案</button>
                    <?php
                        }
                    ?>
                </div>
            </div>
        </form>
    </div>
    <div class="layui-footer">© 医院档案</div>
</div>
<script src="__TEMPLATE__/layui/jquery-1.7.2.min.js"></script>
<script src="__TEMPLATE__/layui/layui.js"></script>
<script>
    layui.use(['element', 'form'], function () {
        var element = layui.element;
        var form = layui.form;
        form.on('submit(submit)', function (data) {
            var loadIndex = layer.load(1, {
                shade: [0.5, '#000']
            });
            $.ajax({
                url: '?act=saveDo',
                data: data.field,
                dataType: 'json',
                success: function (res) {
                    layer.close(loadIndex);
                    if (res.code == 0) {
                        window.location.href = window.location.href;
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });
        form.on('submit(submitFangan)', function (data) {
            var loadIndex = layer.load(1, {
                shade: [0.5, '#000']
            });
            $.ajax({
                url: '?act=submitFangan',
                data: data.field,
                dataType: 'json',
                success: function (res) {
                    layer.close(loadIndex);
                    if (res.code == 0) {
                        window.location.href = window.location.href;
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });
        form.on('submit(resetFangan)', function (data) {
            var loadIndex = layer.load(1, {
                shade: [0.5, '#000']
            });
            $.ajax({
                url: '?act=resetFangan',
                data: data.field,
                dataType: 'json',
                success: function (res) {
                    layer.close(loadIndex);
                    if (res.code == 0) {
                        window.location.href = window.location.href;
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });
    });
    $(function () {
        $('#logout').bind('click', function () {
            var loadIndex = layer.load(1, {
                shade: [0.5, '#000']
            });
            $.ajax({
                url: 'logout.php',
                success: function (res) {
                    window.location.href = 'login.php';
                }
            });
        });
    });
</script>
</body>
</html>